package com.netty.demo;

import java.nio.ByteBuffer;

/**
 * @Auther: Admin
 * @Date: 2021/4/13 17:38
 * @Description:
 */
public class TestByteBufferRead {

    public static void main(String[] args) {

        ByteBuffer buffer = ByteBuffer.allocate(10);

        buffer.put(new byte[]{'a','b','c','d'});

        buffer.flip();

//        System.out.println((char) buffer.get());
//        System.out.println((char) buffer.get());
//
//        buffer.rewind();// 重新position为0
        System.out.println((char) buffer.get());
        System.out.println((char) buffer.get());


        buffer.mark();// mark() 配合reset重置
        System.out.println((char) buffer.get());
        System.out.println((char) buffer.get());
        buffer.reset();
        System.out.println((char) buffer.get());



    }

}
